package com.zc.operator.controller;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.zc.operator.domain.ChargeStationPriceTactics;
import com.zc.operator.service.ChargeStationPriceTacticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/operator/priceTactics")
public class ChargeStationPriceTacticsController extends BaseController {
    
    @Autowired
    private ChargeStationPriceTacticsService service;

    /**
     * 分页查询
     */
    @PreAuthorize("@ss.hasPermi('operator:tactics:list')")
    @GetMapping("/list")
    @DataScope(deptAlias = "s")
    public TableDataInfo listOfCategoryId(ChargeStationPriceTactics tactics)
    {
        startPage();
        return getDataTable(service.getList(tactics));
    }

    /**
     * 查询
     */
    @PreAuthorize("@ss.hasPermi('operator:tactics:info')")
    @GetMapping("/{id}")
    public AjaxResult info(@PathVariable Long id)
    {
        return AjaxResult.success(service.selectById(id));
    }

    /**
     * 新增
     * @param tactics 新整参数
     * @return 新增操作结果
     */
    @PreAuthorize("@ss.hasPermi('operator:tactics:add')")
    @Log(title = "新增设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody ChargeStationPriceTactics tactics) {
        return toAjax(service.insertSelective(tactics));
    }

    /**
     * 修改
     * @param tactics 修改参数
     * @return 修改操作结果
     */
    @PreAuthorize("@ss.hasPermi('operator:tactics:edit')")
    @Log(title = "修改设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody ChargeStationPriceTactics tactics) {
        return toAjax(service.modifyById(tactics));
    }

    /**
     * 删除
     * @param id id
     * @return 删除操作结果
     */
    @PreAuthorize("@ss.hasPermi('operator:tactics:remove')")
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @DeleteMapping("{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(service.deleteById(id));
    }
}
